package com.ubi.app.dao;

import com.ubi.app.domain.Position;
import com.ubi.core.database.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface PositionMapper extends BaseMapper {
    @Delete({
        "delete from position",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into position (id, longtitude, ",
        "latitude, name, ",
        "biz_id, biz_type, ",
        "create_time)",
        "values (#{id,jdbcType=BIGINT}, #{longtitude,jdbcType=DECIMAL}, ",
        "#{latitude,jdbcType=DECIMAL}, #{name,jdbcType=VARCHAR}, ",
        "#{bizId,jdbcType=VARCHAR}, #{bizType,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(Position record);

    @InsertProvider(type=PositionSqlProvider.class, method="insertSelective")
    int insertSelective(Position record);

    @Select({
        "select",
        "id, longtitude, latitude, name, biz_id, biz_type, create_time",
        "from position",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="longtitude", property="longtitude", jdbcType=JdbcType.DECIMAL),
        @Result(column="latitude", property="latitude", jdbcType=JdbcType.DECIMAL),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="biz_id", property="bizId", jdbcType=JdbcType.VARCHAR),
        @Result(column="biz_type", property="bizType", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    Position selectByPrimaryKey(Long id);

    @UpdateProvider(type=PositionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Position record);

    @Update({
        "update position",
        "set longtitude = #{longtitude,jdbcType=DECIMAL},",
          "latitude = #{latitude,jdbcType=DECIMAL},",
          "name = #{name,jdbcType=VARCHAR},",
          "biz_id = #{bizId,jdbcType=VARCHAR},",
          "biz_type = #{bizType,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Position record);
}